﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ERPTOOLS.Class;

namespace ERPTOOLS
{
    public partial class Sql : Form
    {
        LinkLabel _lbl;
        public Sql(LinkLabel linklbl)
        {
            InitializeComponent();
            _lbl=linklbl;
        }

        private void button3_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void Sql_Load(object sender, EventArgs e)
        {
            if (_lbl.Name == "llblchkpur")
            {
                richTextBox1.Text = XMLHelper.GetInnerTextByXpath("Configure.xml", "//PurSql").ToString().Replace("<", "&lt;").Replace(">", "&gt;");
            }
            if (_lbl.Name == "llblchkcut")
            {
                richTextBox1.Text = XMLHelper.GetInnerTextByXpath("Configure.xml", "//CutSql").ToString();
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (richTextBox1.Text == "")
            {
                MessageBox.Show("SQL为空，请点【取消】按钮");
            }
            else
            {
                if (_lbl.Name == "llblchkpur")
                {
                    XMLHelper.CreateOrUpdateXmlNodeByXPath("Configure.xml", "//Check", "PurSql", richTextBox1.Text);
                }
                if (_lbl.Name == "llblchkcut")
                {
                    XMLHelper.CreateOrUpdateXmlNodeByXPath("Configure.xml", "//Check", "CutSql", richTextBox1.Text);
                }
                this.Close();
            }
        }
    }
}
